export const isExternal = (path: string) => {
  return /^(https?:|mailto:|tel:)/.test(path)
}

export const validUsername = (str: string) => {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

// 新增月卡-自定义校验车牌号
export const validaeCarNumber = (rule: any, value: any, callback: any) => {
  const plateNumberRegex = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使]{1}[A-Z]{1}[A-Z0-9]{5,6}$/
  if (plateNumberRegex.test(value)) {
      callback()
  } else {
      callback(new Error('请输入正确的车牌号'))
  }
}

// 新增企业 - 手机号校验
export const validMobile = (rule: any, mobile: any, callback: any) => {
    if (/^1[3-9]\d{9}$/.test(mobile)) {
        callback()
    } else {
        callback('请输入正确手机号')
    }
}